var TechnologyProcessingTableList = {id: "TechnologyProcessingTableList",seItem: null,table: null,layerIndex: -1};//医生机加工表格初始化

TechnologyProcessingTableList.initColumn = function () {//初始化表格的列
    var columns = [
        {field: 'selectItem', radio: true},
        {title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
        {title: 'customerId', field: 'customerId', visible: false, align: 'center', valign: 'middle'},
        {title: 'reservationsId', field: 'reservationsId', visible: false, align: 'center', valign: 'middle'},
        {title: '患者姓名', field: 'customerName', align: 'center', valign: 'middle', sortable: true,width:110},
        {title: '医生', field: 'doctor', align: 'center', valign: 'middle', sortable: true,width:90},
        {title: '项目名称', field: 'payServiceName', align: 'center', valign: 'middle', sortable: true,width:110},
        {title: '数量', field: 'number', align: 'center', valign: 'middle', sortable: true,width:80},
        {title: '单价', field: 'price', align: 'center', valign: 'middle', sortable: true,width:80},
        {title: '金额', field: 'amount', align: 'center', valign: 'middle', sortable: true,width:80},
        {title: '实付金额', field: 'amountActually', align: 'center', valign: 'middle', sortable: true,width:110},
        {title: '所属类别', field: 'type', align: 'center', valign: 'middle', sortable: true,width:110},
        {title: '门店', field: 'arrivalStore', align: 'center', valign: 'middle', sortable: true,width:100},
        {title: '订单状态', field: 'status', align: 'center', valign: 'middle', sortable: true,width:110},
        {title: '加工单位', field: 'processUnit', align: 'center', valign: 'middle', sortable: true,width:170},
        {title: '备注', field: 'remarks', align: 'center', valign: 'middle', sortable: true,width:120},
        {title: '创建时间', field: 'createTime', align: 'center', valign: 'middle', sortable: true,width:170},
        {
            title: '操作', field: 'id', align: 'center', valign: 'middle', sortable: true, width: 80,
            formatter: function (value, row, index) {
                var ids = row.id
                return '<button title="编辑" style="background: #ffffff;border: 1px solid #cccccc;padding: 1px 4px 0px 5px;" onclick="TechnologyProcessingTableList.updateProcess(' + "'" + ids + "'" + ')" type="button" class="btn"><span class="glyphicon glyphicon-edit"></span></button> '+
                    '<button title="删除" onclick="TechnologyProcessingTableList.deleteProcess(' + "'" + ids + "'" + ')" type="button" class="btn" style="background: #ffffff;border: 1px solid #cccccc;padding: 1px 4px 0px 5px;"><span class="glyphicon glyphicon-trash"></span></button>'
            }
        }
    ];return columns;
};

TechnologyProcessingTableList.check = function () {// 检查是否选中
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length == 0) {Feng.info("请先选中表格中的某一记录！");return false;}
    else {TechnologyProcessingTableList.seItem = selected[0];return true;}
};

TechnologyProcessingTableList.close = function () {parent.layer.close(parent.layer.getFrameIndex(window.name));};//关闭此对话框

TechnologyProcessingTableList.updateProcess = function (ids) {// 编辑机加工
    var index = layer.open({
        type: 2,
        title: '编辑',
        area: ['70%', '70%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/update_process/' + ids
    });this.layerIndex = index;
};

TechnologyProcessingTableList.deleteProcess = function (ids) {//删除机加工
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/delete_process",
        type: "post",
        data: {ids: ids},
        success: function (data) {Feng.success('操作成功!');window.TechnologyProcessingTableList.table.refresh();
        },error: function (data) {alert('没有权限，请联系管理员!');}
    });
};

TechnologyProcessingTableList.search = function () {TechnologyProcessingTableList.table.refresh();};//查询机加工列表记录

$(function () {
    var defaultColunms = TechnologyProcessingTableList.initColumn();var reservationsId = $("#reservationsId").val();
    var table = new BSTable(TechnologyProcessingTableList.id, "/doctorLooked/processingTableList/" + reservationsId, defaultColunms);
    table.setPaginationType("client");//客户端分页
    TechnologyProcessingTableList.table = table.init();TechnologyProcessingTableList.search();
    if($("#tabId").val() == 7){$('#TechnologyProcessingTableList').bootstrapTable('resetView', {height: $(window).height() - 190});};
});